import {request} from '../../utils/http'

Page({
  data: {
    curIdx: 0,
    tabs: [
      {
        title: '未使用',
        subTitle: '描述文案描述',
        status: 0
      },
      {
        title: '已使用',
        subTitle: '描述',
        status: 1
      },
      {
        title: '已失效',
        subTitle: '描述',
        status: -1
      }
    ],
    list:[],
    loading: false
  },
  onLoad() {
    this.getList()
  },
  getList(){
    request('/my_coupons','get',{status:this.data.tabs[this.data.curIdx].status}).then(res => {
      if (res.code == 200) {
        this.setData({
          list:res.data
        })
      }
    })
  },
  handleChangeTab(e){
    console.log(e)
    if (e == this.data.curIdx) {
      return
    }
    this.setData({
      curIdx:e
    }, () => {
      this.getList()
    })
  }
});
